<%= render  :partial => "apo/navigation" %>

<div id="containerBody">

	<div style="margin-bottom: 0.5em">
		<% form_tag({:action => "list"}, {:style => "display: inline"}) do %>
  		Showing:
			<% unless params[:filter].nil? %>
				<%= select "filter", "type",
				[
					["All", nil],
					["Service", "Service"],
					["Fellowships", "Fellowship"],
					["LDCs", "Leadership"],
					["Fundraisers", "Fundraiser"],
					["Active Meetings", "Active Meeting"],
					["Pledge Meetings", "Pledge Meeting"],
					["Dues", "Dues"],
					["Office Hours", "Office Hour"],
					["Committees", "Committee"],
					["Ceremonies", "Ceremony"],
					["Indy Hours", "Indy Hours"],
					["Pledge Reqs", "Pledge Req"],
					["Other", "Other"]
				],
				{:selected => params[:filter][:type]},
				{:onchange => 'this.form.submit();'} %>
			<% else %>
				<%= select "filter", "type",
				[
					["All", nil],
					["Service", "Service"],
					["Fellowships", "Fellowship"],
					["LDCs", "Leadership"],
					["Fundraisers", "Fundraiser"],
					["Active Meetings", "Active Meeting"],
					["Pledge Meetings", "Pledge Meeting"],
					["Dues", "Dues"],
					["Office Hours", "Office Hour"],
					["Committees", "Committee"],
					["Ceremonies", "Ceremony"],
					["Indy Hours", "Indy Hours"],
					["Pledge Reqs", "Pledge Req"],
					["Other", "Other"]
				],
				{},
				{:onchange => 'this.form.submit();'} %>
			<% end %>
		<% end %>
		<% if session[:user].admin? %>
			<% form_tag({:action => "create" , :id => params[:id]}, {:style => "display: inline"}) do %>
				<%= submit_tag "Create New Event" %>
			<% end %>
		<% end %>
		<%= submit_tag "Submit Indy Hours", :onclick => "window.location = 'indy_hour_submission'" %>
	</div>

	<div class="container eventContainer">

		<div class="cellRow cellRowHeader">
			<div class="cellBlock" style="text-align: left;">
				<%= link_to "Event Name" , :action => "list" , :id => @event, :sort_by => "name" %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Date" , :action => "list" , :id => @event %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Time" , :action => "list" , :id => @event %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Hours" , :action => "list" , :id => @event, :sort_by => "hours" %>
			</div>
			<div class="cellBlock" style="text-align: left;">
				MIC
			</div>
			<div class="cellBlock" style="text-align: left;">
				<%= link_to "Type" , :action => "list" , :id => @event, :sort_by => "event_type" %>
			</div>
			<div class="cellBlock" style="text-align: left;">
				<%= link_to "Full" , :action => "list" , :id => @event, :sort_by => "full" %>
			</div>
			<% if session[:user].admin? %>
				<div class="cellBlockNoBorder cellBlockNoBorderL">
				</div>
				<div class="cellBlockNoBorder cellBlockNoBorderL">
				</div>
			<% end %>
		</div>

		<% counter = 0 %>
		<% @events.each  do |event| %>
			<div class="cellRow cellRow<%= counter % 2 == 0?1:2 %> highlightRow">
				<div class="cellBlock">
					<% if session[:user].admin? and event.name.length > 38 %>
						<%= link_to h(event.name[0,37]), :action => "show" , :id => event %>...
					<% else %>
						<%= link_to h(event.name), :action => "show" , :id => event %>
					<% end %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.date.strftime("%A")[0,3]%><%=h event.date.strftime(", %b %d").center(0) %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.date.strftime("%I:%M %p").center(0) %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.hours %>
				</div>
				<div class="cellBlock">
					<% if !(event.mic_id == nil) %>
						<%= link_to h(event.mic.full_name) , :controller => "members", :action => "show" , :id => event.mic %>
					<% else %>
    					&nbsp;
    				<% end %>
				</div>
				<div class="cellBlock">
					<%=h event.event_type %>
				</div>
				<div class="cellBlock">
					<%=h event.full ? "Yes" : "No" %>
				</div>

				<% if session[:user].admin? %>
				<div class="cellBlockNoBorder cellBlockNoBorderL" style="text-align: center;">
					<%= link_to "edit", :action => "edit", :id => event %>
				</div>
				<div class="cellBlockNoBorder cellBlockNoBorderL" style="text-align: center;">
					<%= link_to "remove", :action => "remove", :id => event %>
				</div>
				<% end %>
			</div>
			<% counter = counter + 1 %>
		<% end %>

	</div>

</div>
